/*<summary>
Created By : Preeti
Created On : 10/18/2008
Class Name : Ward_Mapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Utils;

namespace AdminController
{
    public class Ward_Mapper
    {
        public bool Load_Ward_DATA(string WardId, Ward objWard)
        {
            if (!(objWard == null))
            {
                ezUtilsAdapter DBL = new ezUtilsAdapter();
                int ResultVal;
                bool bresult;
                string WardName;
                string Location;
                string WardType;
                string NumberOfBeds;
                string Remarks;

                WardName = objWard.WardName;
                Location = objWard.Location;
                WardType = objWard.WardType;
                NumberOfBeds = objWard.NumberOfBeds;
                Remarks = objWard.Remarks;

                try
                {
                    ResultVal = DBL.RunSPReturnInteger("SP_SetWard",
                    new SqlParameter("@vchWardId", WardId),
                   new SqlParameter("@vchWardName", WardName),
                     new SqlParameter("@vchLocation", Location),
                     new SqlParameter("@vchWardType", WardType),
                     new SqlParameter("@vchNumberOfBeds", NumberOfBeds),
                     new SqlParameter("@vchRemarks", Remarks));
                    if (ResultVal == 0) { bresult = true; } else { bresult = false; } return bresult;
                }
                catch (SqlException ex)
                {
                    string errorMessage = string.Format(
                        "An Error Occurred While Loading the Ward Information to the DB. Message: {0}", ex.Message);
                    //throw new MappingException(errorMessage, ex);}
                    return false;
                }
                finally
                {
                    DBL.Dispose();
                }
            }

            else { return false; }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}